<?php

namespace app\client\controller\trainer;

use app\common\controller\Frontend;
use app\common\model\banxi\organization\Organization as OrganizationModel;
use app\common\model\banxi\trainer\Trainer as TrainerModel;
use think\db\exception\DbException;
use think\db\exception\PDOException;
use think\exception\ValidateException;
use think\facade\Validate;
use think\validate\ValidateRule;

/**
 * 老师字典
 */
class Trainer extends Frontend
{
    protected array $noNeedLogin = [];

    protected array $noNeedPermission = ['*'];

    public function initialize(): void
    {
        parent::initialize();
    }



    /**
     * 分页Select查询
     * @return void
     * @throws DbException
     */
    public function listSelectPage(): void
    {
        $param = $this->request->param(['index', 'limit', 'orderBy', "query"]);
        $TrainerModel = new TrainerModel();
        $organizationModel = new OrganizationModel();
        $organizationId = $this->auth->organizationId;
        $param['query']['IN_organizationId'] = $organizationModel->getSonOrganization($organizationId);
        //查询条件解析
        $where = get_query($param);
        //获取分页数据
        $pageParams = get_page_params($param);
        $list = $TrainerModel->getListSelectPage($where, $pageParams['page'], $pageParams['limit']);

        $this->ok('操作成功', result_row($list));
    }

}